package com.yoso.shop.interfaces.controller;

import com.yoso.shop.infrastructure.rabbitmq.MessageProducer;
import com.yoso.shop.infrastructure.utils.RabbitMqUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yoso
 * @date 2022/2/17
 */
@RestController
@Slf4j
public class TestController {
    @Autowired
    private RabbitMqUtils mqUtils;
    @Autowired
    private MessageProducer messageProducer;

    @PostMapping("mq")
    public void sendDelayOrderConfirmMsg() {
        log.info("延时订单确认发起：{}");
        System.out.println("mqUtils = " + mqUtils);
        mqUtils.sendDelayOrderConfirmMsg(null);
    }

    @GetMapping("message")
    public void message() {
        messageProducer.publish("开学啦！！！！");
    }
}
